package controllers

import (
	"fmt"
	"strconv"

	"gitee.com/ly_610/myblog/models"
	"gitee.com/ly_610/myblog/utils"
)

type ShowArticleController struct {
	// beego.Controller
	BaseController
}

func (c *ShowArticleController) Get() {
	idStr := c.Ctx.Input.Param(":id")
	id, _ := strconv.Atoi(idStr)
	fmt.Println("id: ", id)

	// 获取id所对应的文章的信息
	art := models.QueryArticleWithId(id)
	c.Data["Title"] = art.Title
	// c.Data["Content"] = art.Content
	c.Data["Content"] = utils.SwitchMarkdownToHtml(art.Content)
	c.TplName = "show_article.html"
}
